/**
 * Decider class definition
 * This parent behavior selects one of it's children to update.
 * 
 * To select a child, it starts from the beginning of it's children vector
 * and goes one by one until it finds one that passes the CheckCondition test.
 * It then updates that child until it finished.
 * If the child finishes with failure, it continues down the list looking another
 * candidate to update, and if it doesn't find it, it finishes with failure. 
 * If the child finishes with success, the Selector considers it's task done and 
 * bails with success. 
 * 
 * Original credit for a java implementation to: http://magicscrollsofcode.blogspot.com/2010/12/behavior-trees-by-example-ai-in-android.html
 */

#ifndef DECIDER_H_
#define DECIDER_H_

#include "ParentBehavior.h"


class Decider : public ParentBehavior 
{
public:

	/**
	 * Creates a new instance of the Selector class
	 */
	Decider(std::string incName = "") : ParentBehavior(incName)	{}     

	/**
	 * Chooses the new task to update.
	 * @return The new task, or null if none was found
	 */
	int ChooseNewTask();
	
	/**
	 * In case of child finishing with failure we find a new one to update,
	 * or fail if none is to be found
	 */
	void BehaviorFailed();

	/**
	 * In case of child finishing with sucess, our job here is done, finish with sucess
	 * as well
	 */
	void BehaviorSucceeded() {	control->FinishWithSuccess();	}
};

#endif
